import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/login")
public class loginServlet extends HttpServlet {
    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        System.out.println("login服务触发了");
        req.setCharacterEncoding("utf-8");
        String username = req.getParameter("username");
        String pwd = req.getParameter("pwd");
        //tomcat 默认使用iso8859-1对字符编码
        //System.out.println( new String(username.getBytes("iso-8859-1"),"utf-8")  );
        System.out.println(username);
        System.out.println(pwd);

        /*
         * 查数据库 看数据对不对
         * */
        //给页面反馈
        res.setContentType("text/html;charset=utf-8");
        PrintWriter writer = res.getWriter();
        writer.print(username+"<h1>loginok.....<h1>");
        writer.close();

    }
}
